<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2020/4/26
 * Time: 16:41
 */

namespace app\common\service;

//文件查杀
class HostFileScreening
{
    /**
     * @name: 查杀运行状态
     * @Param:
     * @Description:
     * @Author: foo
     * @Date: 2019-08-30 14:09:41
     */
    function runStatus ($host_id)
    {
        $return = db('HostFileScreening')->where('host_id', $host_id)
            ->field('status,filensum,complete,danger,doubtable,stime,etime')
            ->find();

        return $return;
    }

    /**
     * @name: 开始查杀
     * @Param:
     * @Description:
     * @Author: foo
     * @Date: 2019-08-30 14:09:41
     */
    function start ($host_id)
    {
        db('HostFileScreening')->where('host_id', $host_id)->update(
            [
                'status' => model('HostFileScreening')->STATUS_INITING,//设置为状态
                'filensum' => 0,//文件总个数
                'complete' => 0,//已完成扫描文件个数
                'danger' => 0,//危险文件个数
                'doubtable' => 0,//疑问文件个数
                'stime' => time(),//扫描开始时间
                'etime' => 0,//扫描结束时间

            ]
        );
    }
    /**
     * @name: 停止查杀
     * @Param:
     * @Description:
     * @Author: foo
     * @Date: 2019-08-30 14:09:41
     */
    function stop ($host_id)
    {
        db('HostFileScreening')->where('host_id', $host_id)->update(
            [
                'status' => model('HostFileScreening')->STATUS_COMPLETE,
            ]
        );
    }

    /**
     * @name: 暂停查杀
     * @Param:
     * @Description:
     * @Author: foo
     * @Date: 2019-08-30 14:09:41
     */
    function pause ($host_id)
    {
        db('HostFileScreening')->where('host_id', $host_id)->update(
            [
                'status' => model('HostFileScreening')->STATUS_PAUSE,
            ]
        );
    }

    /**
     * @name: 继续查杀
     * @Param:
     * @Description:
     * @Author: foo
     * @Date: 2019-08-30 14:09:41
     */
    function continue ($host_id)
    {
        db('HostFileScreening')->where('host_id', $host_id)->update(
            [
                'status' => model('HostFileScreening')->STATUS_SCANING,
            ]
        );
    }
}